package com.onion.codegen.gen;

import java.util.List;

import com.onion.codegen.bean.GeneratorProperties;
import com.onion.codegen.bean.JavaBeanProperties;
import com.onion.codegen.utils.FileCreateUtil;
import com.onion.codegen.utils.TableToJavaEntityUtil;

public class EntityGenerator extends BaseGenerator {

	@Override
	public void genJavaClasss(List<JavaBeanProperties> javaPropertiesList, GeneratorProperties javaEntityProperties)
			throws Exception {
		TableToJavaEntityUtil.readyToGenJava(javaPropertiesList, javaEntityProperties);
		for (JavaBeanProperties item : javaPropertiesList) {
			StringBuffer path = new StringBuffer();
			path.append(javaEntityProperties.getPackageName().replace(".", "/"));
			path.append("/").append(item.getJavaName()).append(".java");
			FileCreateUtil.getInstance().writeFile(javaEntityProperties.isForce(), javaEntityProperties.getBaseFoler(),path.toString(), item.getJavaContent());
		}
	}

}
